package StudentManagement;

public class Student {

    // 私有属性：学号、姓名、专业、成绩
    private String studentId;
    private String name;
    private String major;
    private double score;

    // 有参构造方法（初始化学号、姓名、专业）
    public Student(String studentId, String name, String major) {
        this.studentId = studentId;
        this.name = name;
        this.major = major;
    }

    // Getter/Setter 方法：用于访问和修改私有属性
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        if (score >= 0 && score <= 100) {
            this.score = score;
        } else {
            System.out.println("成绩不合法（必须0-100分）");
        }
    }

    // 自定义方法：显示学生完整信息
    public void showInfo() {
        System.out.println("学号：" + studentId + "，姓名：" + name +
                "，专业：" + major + "，成绩：" + score + "分");
    }
}